package cn.jbit.reactor;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.ServerSocketChannel;

/**
 * 源码学院只为培养优秀的bat程序员而生
 *
 * @author 学员张在成
 * @data 2020/8/8
 */
public class ReactorServer {

    public static void main(String[] args) throws IOException {

        //建立一个server端的通道
        ServerSocketChannel  serverSocketChannel=ServerSocketChannel.open();
        //绑定服务端口
        serverSocketChannel.socket().bind(new InetSocketAddress(8080));
        //channel直接调用accept建立连接，设置为true
        serverSocketChannel.configureBlocking(false);
        //Reactor是入口，最初给一个channel注册上去的事件都是accept
        new Thread(new Acceptor(serverSocketChannel),"reactor-001").start();
    }
}
